import { $get, $post, $setHeader } from '../utils/require'
import md5 from 'js-md5'
//导入消息框
import { $msg } from '../utils/msg'

export const $login = async (params) => {
    params.loginPwd = md5(md5(params.loginPwd).split('').reverse().join(''))
    let { data: { message, success, token } } = await $get('Admin/Login', params)
    if (success) {
        $msg(message)
        sessionStorage.setItem('token', token)
        $setHeader('token', token)
        return true
    } else {
        $msg(message, 'error')
        // return false
    }
    return success
}